﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Game : MonoBehaviour
{
    public enum Game_Status
    {
        Ready,
        InGame,
        GameOver
    }
    public Game_Status status;
    public Game_Status Status
    {
        get { return status; }
        set { status = value;

            UpdateUI();
        }
    }

    public GameObject PanelReady;
    public GameObject PanelInGame;
    public GameObject PanelGameOver;
    public Player player;

    public PipeLineManager pipeLineManager;
   
    // Start is called before the first frame update
    void Start()
    {
        this.PanelReady.SetActive(true);
        this.Status = Game_Status.Ready;
        player.OnDeath += Player_Ondeath;
    }

    private void Player_Ondeath()
    {
        this.Status = Game_Status.GameOver;
        pipeLineManager.Stop();
    }

    public void StartGame()
    {
        this.Status = Game_Status.InGame;
       

        pipeLineManager.StartRun();//生成管道
        player.Flay();


    }
    public void UpdateUI()
    {
        PanelReady.SetActive(Status == Game_Status.Ready);
        PanelInGame.SetActive(Status == Game_Status.InGame);
        PanelGameOver.SetActive(Status == Game_Status.GameOver);

    }
    public void Restart()
    {
        this.Status = Game_Status.Ready;
        pipeLineManager.Init();
        player.Init();
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}
